package com.ase.数据结构;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author gyhstart
 * @create 2021/2/28 - 20:08
 **/
public class QueueTest {
    public static Boolean MyQueue() {
        Queue queue = new LinkedList();
        queue.add('a');
        queue.add('b');
        queue.add('c');
        queue.add('d');
        queue.add('e');
        System.out.println("queue = " + queue);
        //add(E), offer(E) 在尾部添加
        System.out.println("queue.add('p') = " + queue.add('p'));
        System.out.println("queue.offer('o') = " + queue.offer('o'));
        System.out.println("queue = " + queue);
        // remove(), poll() 删除并返回头部
        System.out.println("queue.poll() = " + queue.poll());
        System.out.println("queue.remove() = " + queue.remove());
        System.out.println("queue = " + queue);
        //element(), peek() 获取但不删除
        System.out.println("queue.element() = " + queue.element());
        System.out.println("queue.peek() = " + queue.peek());
        System.out.println("queue = " + queue);
        return false;
    }

    public static void main(String[] args) {
        MyQueue();
    }
}
